#include "gridlayoutdemo.h"
#include <QGridLayout>
#include <QTextEdit>
#include <QLabel>
#include <QListWidget>
#include <QComboBox>
GridLayoutDemo::GridLayoutDemo(QWidget *parent) :
    QWidget(parent)
{
    resize(400,400);

    QGridLayout *gridlayout=new QGridLayout;
    gridlayout->setColumnMinimumWidth(0,50);
    gridlayout->setColumnMinimumWidth(1,10);
    gridlayout->setColumnMinimumWidth(2,50);
    gridlayout->setColumnMinimumWidth(3,10);
    gridlayout->setColumnMinimumWidth(4,50);

    gridlayout->setColumnStretch(0,1);
    gridlayout->setColumnStretch(2,2);
    gridlayout->setColumnStretch(4,4);
/*
    gridlayout->setRowMinimumHeight(0,30);
    gridlayout->setRowMinimumHeight(1,30);
    gridlayout->setRowMinimumHeight(2,30);
*/
    gridlayout->setRowStretch(0,1);  //设置行高所占比例
    gridlayout->setRowStretch(1,1);
    gridlayout->setRowStretch(2,8);

    gridlayout->addWidget(new QLabel("Font"),0,0);
    gridlayout->addWidget(new QLabel("Font Style"),0,2);
    gridlayout->addWidget(new QLabel("Font Size"),0,4);
/*
    QTextEdit* edit1=new QTextEdit;
    edit1->setAlignment(Qt::AlignHCenter);
    QTextEdit* edit2=new QTextEdit;
    edit2->setAlignment(Qt::AlignHCenter);
    QTextEdit* edit3=new QTextEdit;
    edit3->setAlignment(Qt::AlignHCenter);


    gridlayout->addWidget(edit1,1,0);
    gridlayout->addWidget(edit2,1,2);
    gridlayout->addWidget(edit3,1,4);
*/
    QComboBox *com1=new QComboBox;
    com1->addItems(QStringList()<<"1"<<"2");
    QComboBox *com2=new QComboBox;
    com2->addItems(QStringList()<<"1"<<"2");
    QComboBox *com3=new QComboBox;
    com3->addItems(QStringList()<<"1"<<"2");

    gridlayout->addWidget(com1,1,0);
    gridlayout->addWidget(com2,1,2);
    gridlayout->addWidget(com3,1,4);

    QListWidget *listwidget1=new QListWidget;
    listwidget1->addItems(QStringList()<<"Times"<<"Song"<<"正黑");
    QListWidget *listwidget2=new QListWidget;
    listwidget2->addItems(QStringList()<<"Roma"<<"Italic");
    QListWidget *listwidget3=new QListWidget;
    listwidget3->addItems(QStringList()<<"20"<<"24"<<"30"<<"40");
    gridlayout->addWidget(listwidget1,2,0);
    gridlayout->addWidget(listwidget2,2,2);
    gridlayout->addWidget(listwidget3,2,4);

    setLayout(gridlayout);
}
